package website.lucaswork.survey.mvc.controllers;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice
public class ErrorHandler {

    @ExceptionHandler(Exception.class)
    public ModelAndView serverError(Exception ex) {
        ModelAndView mav = new ModelAndView();
        mav.addObject("message", "Server error. Please contact administrator.");
        mav.setViewName("error");
        return mav;
    }
}
